package net.sk.china.front.service.impl.user;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.sk.china.common.model.user.UserSmsRecord;
import net.sk.china.front.dao.user.UserSmsRecordDao;
import net.sk.china.front.service.user.UserSmsRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * UserSmsRecordServiceImpl 接口实现
 * +----------------------------------------------------------------------
 * // | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
 * // +----------------------------------------------------------------------
 * // | Copyright (c) 2018-2024 聊来 All rights reserved.
 * // +----------------------------------------------------------------------
 * // | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">apache</a> )
 * // +----------------------------------------------------------------------
 * // | @Author: 聊来 <18970881148@qq.com>
 * // +----------------------------------------------------------------------
 * // | DateTime: 2024/6/4 15:15
 * // +----------------------------------------------------------------------
 */

@Service
public class UserSmsRecordServiceImpl extends ServiceImpl<UserSmsRecordDao, UserSmsRecord> implements UserSmsRecordService {

    @Resource
    private UserSmsRecordDao dao;

    /**
     * 统计发送条数
     * @param phone 手机号
     * @param time 查询时间
     * @return {@code long}
     */
    @Override
    public long getCount(String phone, String time) {
        LambdaQueryWrapper<UserSmsRecord> query = new LambdaQueryWrapper<>();
        query.select(UserSmsRecord::getId);
        query.between(UserSmsRecord::getCreateTime, time + " 00:00:00", time + " 23:59:59");
        query.eq(UserSmsRecord::getPhone, phone);

        return dao.selectCount(query);
    }
}
